<?php 

include("config.php");
include("thumb.php");

if (!isset($_GET["id"])) {
	exit;
}

$id = htmlspecialchars($_GET["id"]);

$query="SELECT * FROM gallery where id = ".$id;
$result=mysql_query($query);

$imagedir=mysql_result($result,0,"imagedir");
$fullpath=$gconfig['image-root']."/".$imagedir;

$name=mysql_result($result,0,"name");
$desc=mysql_result($result,0,"desc");

?>

<html>
	<head>
		<?php echo "<title>$name</title>" ?>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="description" content="<?php echo $desc ?>" />
		<meta name="keywords" content="<?php echo $sconfig['meta-keywords'] ?>" />
			
		<script type="text/javascript" src="javascripts/gallery.js"></script>
			
		<link rel="stylesheet" type="text/css" href="stylesheets/gallery.css" />
		
	</head>
	<body>  

	<table class="main-table"><tr><td width="125px" valign="top"></td><td>


	

</td><td></tr><tr><td>

</td>
<td class="main-td">

<div class="main-div">



<?php 

	include('title_bar.php');
	
	echo '<hr/>';
	
	echo '<h2>'.$name.'</h2>';
	echo '<h4>'.$desc.'</h4>';
	
	$files = scandir($fullpath);
	natsort($files);

	$settings = array('w'=>284,'h'=>300,'crop'=>true); 
	$i = 0;
	foreach ($files as &$file) {
		
		if (strncmp($file, ".", 1) != 0 && (substr_count($file, ".jpg") > 0 || substr_count($file, ".JPG") > 0)) {
			
			$imagepath = $fullpath."/".$file;
	   		$size = getimagesize($imagepath);

	   		echo '<div class="image-frame-div-show"><table class="image-frame-table"><tr><td>';
	   		
			echo '<a href="'.$imagepath.'">';

	   		echo '<div name="image-div" class="image-div ';
	    	if ($size[0] > $size[1]) {
	    		echo 'image-landscape';
	    	}
	    	else {
	    		echo 'image-portrait';
	    	}
	    	echo '">';
    	
	    	echo '<img src="'.resize($imagepath,$settings).'" alt="'.$name.' - '.$i.'"/>';	 

	    	$exif = exif_read_data($imagepath, 0, true);
	    	
	    	$datetime = explode(" ", $exif['EXIF']['DateTimeOriginal']);
	    	$dates = explode(":", $datetime[0]);
	    	$datetimestring = $dates[1].'/'.$dates[2].'/'.$dates[0]; #.' '.$datetime[1];
	    	
	    	echo '</div></a>';
	    	
	    	echo '<div class="image-desc-div">';
		    echo '<p class="image-name-span">'.$exif['IFD0']['Title'].'</p>';
		    echo '<p class="image-desc-span">'.$exif['IFD0']['Comments'].'<br/>';
		    echo $datetimestring.'</p>';
		    echo '</div>';
	    	
		    echo '<a href="javascript:showdetails('.$i.')">Details</a>';
		    
		    echo '<div id="image-details-div-'.$i.'" class="image-details-div" style="visibility:hidden">';
		    echo '<p class="image-details-span">Shutter Speed: '.$exif['EXIF']['ExposureTime'].'<br/>';
		    echo 'ISO: '.$exif['EXIF']['ISOSpeedRatings'].'</p>';
		    echo '</div>';
	    	
	    	
	    	echo "</td></tr></table></div>";
	    	$i++;
		}
	}

?>

</div>
</td><td valign="top" width="125px">

<?php 

include("footer.php");

?>
